package vistas.clientes;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;


import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JSeparator;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import app.Odv;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ModificarClienteFrame extends javax.swing.JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JLabel jLabel2;
	private JLabel jLabel3;
	private JLabel jLabel4;
	private JLabel jLabel5;
	private JButton jButtonGuardar;
	private JTextField jTextFieldTelefono;
	private JLabel jLabel11;
	private JTextField jTextFieldLocalidad;
	private JLabel jLabel10;
	private JTextField jTextFieldDepto;
	private JLabel jLabel9;
	private JTextField jTextFieldPiso;
	private JLabel jLabel8;
	private JTextField jTextFieldNumero;
	private JLabel jLabel7;
	private JTextField jTextFieldCalle;
	private JLabel jLabel6;
	private JTextField jTextFieldRazonSocial;
	private JSeparator jSeparator1;
	private JComboBox jComboBox1;
	private JLabel jLabel1;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				ModificarClienteFrame inst = new ModificarClienteFrame();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public ModificarClienteFrame() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				jLabel1 = new JLabel();
				getContentPane().add(jLabel1);
				jLabel1.setText("SELECCIONE NUMERO");
				jLabel1.setBounds(12, 20, 146, 16);
			}
			{
				jLabel2 = new JLabel();
				getContentPane().add(jLabel2);
				jLabel2.setText("DE");
				jLabel2.setBounds(42, 48, 28, 16);
			}
			{
				jLabel3 = new JLabel();
				getContentPane().add(jLabel3);
				jLabel3.setText("CLIENTE");
				jLabel3.setBounds(32, 76, 72, 16);
			}
			{
				
				Odv s= Odv.getinstancia();
				
				
				jComboBox1 = new JComboBox();
				List<String> lista = s.listaId();
				
				getContentPane().add(jComboBox1);
				
				for(String i: lista)
					jComboBox1.addItem(i);
			
				jComboBox1.setBounds(198, 36, 67, 23);
				jComboBox1.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						System.out.println("jComboBox1.actionPerformed, event="+evt);
						Odv s=Odv.getinstancia();
						
						String i=(String) jComboBox1.getSelectedItem();
						
						
						jTextFieldCalle.setText(s.buscarCliente(i).getDomicilio().getCalle());
						jTextFieldDepto.setText(s.buscarCliente(i).getDomicilio().getDepartamento());
						jTextFieldLocalidad.setText(s.buscarCliente(i).getDomicilio().getLocalidad());
						jTextFieldNumero.setText(s.buscarCliente(i).getDomicilio().getNumero());
						jTextFieldPiso.setText(s.buscarCliente(i).getDomicilio().getPiso());
						jTextFieldRazonSocial.setText(s.buscarCliente(i).getRazonSocial());
						jTextFieldTelefono.setText(s.buscarCliente(i).getTelefono());
						
						
						
						
					}
				});
			}
			{
				jSeparator1 = new JSeparator();
				getContentPane().add(jSeparator1);
				jSeparator1.setBounds(0, 129, 379, 10);
			}
			{
				jLabel4 = new JLabel();
				getContentPane().add(jLabel4);
				jLabel4.setText("MODIFIQUE LOS VALORES QUE DESEE");
				jLabel4.setBounds(77, 145, 218, 16);
			}
			{
				jLabel5 = new JLabel();
				getContentPane().add(jLabel5);
				jLabel5.setText("RAZON SOCIAL: ");
				jLabel5.setBounds(0, 219, 105, 16);
			}
			{
				jTextFieldRazonSocial = new JTextField();
				getContentPane().add(jTextFieldRazonSocial);
				jTextFieldRazonSocial.setBounds(136, 219, 174, 23);
			}
			{
				jLabel6 = new JLabel();
				getContentPane().add(jLabel6);
				jLabel6.setText("CALLE: ");
				jLabel6.setBounds(0, 282, 84, 16);
			}
			{
				jTextFieldCalle = new JTextField();
				getContentPane().add(jTextFieldCalle);
				jTextFieldCalle.setBounds(136, 279, 174, 23);
			}
			{
				jLabel7 = new JLabel();
				getContentPane().add(jLabel7);
				jLabel7.setText("NUMERO: ");
				jLabel7.setBounds(0, 335, 84, 16);
			}
			{
				jTextFieldNumero = new JTextField();
				getContentPane().add(jTextFieldNumero);
				jTextFieldNumero.setBounds(137, 332, 174, 23);
			}
			{
				jLabel8 = new JLabel();
				getContentPane().add(jLabel8);
				jLabel8.setText("PISO: ");
				jLabel8.setBounds(0, 388, 45, 16);
			}
			{
				jTextFieldPiso = new JTextField();
				getContentPane().add(jTextFieldPiso);
				jTextFieldPiso.setBounds(137, 385, 174, 23);
			}
			{
				jLabel9 = new JLabel();
				getContentPane().add(jLabel9);
				jLabel9.setText("DEPARTAMENTO: ");
				jLabel9.setBounds(0, 437, 119, 16);
			}
			{
				jTextFieldDepto = new JTextField();
				getContentPane().add(jTextFieldDepto);
				jTextFieldDepto.setBounds(137, 434, 174, 23);
			}
			{
				jLabel10 = new JLabel();
				getContentPane().add(jLabel10);
				jLabel10.setText("LOCALIDAD: ");
				jLabel10.setBounds(0, 485, 119, 16);
			}
			{
				jTextFieldLocalidad = new JTextField();
				getContentPane().add(jTextFieldLocalidad);
				jTextFieldLocalidad.setBounds(137, 482, 174, 23);
			}
			{
				jLabel11 = new JLabel();
				getContentPane().add(jLabel11);
				jLabel11.setText("TELEFONO: ");
				jLabel11.setBounds(0, 533, 131, 16);
			}
			{
				jTextFieldTelefono = new JTextField();
				getContentPane().add(jTextFieldTelefono);
				jTextFieldTelefono.setBounds(136, 530, 174, 23);
			}
			{
				jButtonGuardar = new JButton();
				getContentPane().add(jButtonGuardar);
				jButtonGuardar.setText("GUARDAR");
				jButtonGuardar.setBounds(148, 595, 117, 23);
				jButtonGuardar.addActionListener(new ActionListener() {
					
					
					public void actionPerformed(ActionEvent evt) {
						System.out.println("jButtonGuardar.actionPerformed, event="+evt);
						Odv s = Odv.getinstancia();
						
						s.modificarCliente((String) jComboBox1.getSelectedItem(), jTextFieldRazonSocial.getText(), jTextFieldCalle.getText(), 
								jTextFieldNumero.getText(), jTextFieldPiso.getText(), 
								jTextFieldDepto.getText(), jTextFieldLocalidad.getText(),jTextFieldTelefono.getText());
						
						Cambios c = new Cambios();
						c.setVisible(true);
						c.setLocationRelativeTo(null);
						
						
						
					}
				});
			}
			pack();
			this.setSize(400, 694);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
